<include file="Common:minheader" />
<!-- /. NAV SIDE  -->
<script type="text/javascript" charset="utf-8" src="__UEDITOR__/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__UEDITOR__/ueditor.all.js"></script>
<script type="text/javascript" src="__UEDITOR__/lang/zh-cn/zh-cn.js"></script>
<form class="layui-form" action="">
	<input type="hidden" name="old_course_id" value="{$info.id}">
	<input type="hidden" name="level" value="{$info.level}" id="level">
    <input type="hidden" name="color" value="{$info.color}" id="color">
	<div class="layui-form-item">
		<label class="layui-form-label">名称</label>
		<div class="layui-input-block">
		  <input value="{$info.title}" type="text" name="title" required  lay-verify="required" placeholder="请输入门店名称" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">所属场馆</label>
		<div class="layui-input-block">
			<select name="store_id" lay-verify="required">
				<option value="">请选择</option>
				<notempty name="storeList">
					<volist name="storeList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$info['store_id'] eq $vo['id']">selected</if>>{$vo.title}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">课程分类</label>
		<div class="layui-input-block">
			<select name="cate_id">
				<option value="">请选择</option>
				<notempty name="cateList" lay-verify="required">
					<volist name="cateList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$info['cate_id'] eq $vo['id']">selected</if>>{$vo.title}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">所属教练</label>
		<div class="layui-input-block">
			<select name="coach_id" lay-verify="required" lay-search="">
				<option value="">请选择</option>
				<notempty name="coachList">
					<volist name="coachList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$info['coach_id'] eq $vo['id']">selected</if>>{$vo.name}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">所属教室</label>
		<div class="layui-input-block">
			<select name="classroom_id" lay-verify="required">
				<option value="">请选择</option>
				<notempty name="classRoomList">
					<volist name="classRoomList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$info['classroom_id'] eq $vo['id']">selected</if>>{$vo.name}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图片</label>
		<div class="layui-input-block">
			<div class="layui-upload">
			  <button type="button" class="layui-btn" id="test2">上传图片</button>
			  <div class="layui-upload-list" id="demo2" data-id="">
				<if condition="!empty($info['image_url'])">
					<div class="imgcss"><input type="hidden" name="image_url" id="smallimage1" value="{$info.image_url}"><a href="{$info.image_url}" target="_blank"><img src="{$info.image_url}" width="150"></a></div>
				</if>
			  </div>
			  <div id="demoText1"></div>
			</div>
			<div>尺寸:750*360</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">内页图片</label>
		<div class="layui-input-block">
			<div class="layui-upload">
			  <button type="button" class="layui-btn" id="test3">上传图片</button>
			  <div class="layui-upload-list" id="demo3" data-id="">
				<if condition="!empty($info['image_url'])">
					<div class="imgcss"><input type="hidden" name="image_url2" id="smallimage2" value="{$info.image_url2}"><a href="{$info.image_url2}" target="_blank"><img src="{$info.image_url2}" width="150"></a></div>
				</if>
			  </div>
			  <div id="demoText2"></div>
			</div> 
			<div>尺寸:750*360</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">预约人数</label>
		<div class="layui-input-block">
		  <input value="{$info.nums}" type="text" name="nums" required  lay-verify="required" placeholder="请输入可预约人数" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">预备人数</label>
		<div class="layui-input-block">
		  <input value="{$info.t_nums}" type="text" name="t_nums" required  lay-verify="required" placeholder="请输入可预备人数" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">颜色</label>
		<div class="layui-input-block">
		    <div id="layColor"></div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">课程星级</label>
		<div class="layui-input-block">
		    <div id="rateNums"></div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">上课日期</label>
		<div class="layui-input-block">
			<input value="{$info.course_date}" type="text" name="course date" placeholder="请选择上课日期" autocomplete="off" class="layui-input" id="courseDate">
		</div>
	</div>
	<div id="time-select">
		<div class="layui-form-item">
			<label class="layui-form-label">开始时间</label>
			<div class="layui-input-block">
				<input value="{$info.begin_time}" type="text" name="begin_time" placeholder="请选择上课开始时间" autocomplete="off" class="layui-input" id="startDate">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">结束时间</label>
			<div class="layui-input-block">
				<input value="{$info.end_time}" type="text" name="end_time" placeholder="请选择上课结束时间" autocomplete="off" class="layui-input" id="endDate">
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">取消时间</label>
		<div class="layui-input-inline">
		  <input value="{$info.cancel_time}" type="text" name="cancel_time" placeholder="请输入不可取消时间" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">分钟</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">扣卡次数</label>
		<div class="layui-input-inline">
			<input value="{$info.card_nums}" type="text" name="card_nums" placeholder="请输入扣卡次数" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">次</div>
	</div>
	<div class="layui-form-item layui-form-text" style="z-index: 1;">
		<label class="layui-form-label">内容</label>
		<div class="layui-input-block">
		  <script type="text/plain" id="myEditor" name="content" style="width:100%;height:240px;">{$info.content}</script>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">序号</label>
		<div class="layui-input-inline">
		  <input value="{$info.sort}" type="text" name="sort" placeholder="请输入序号" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">数字越大排序越靠前</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">全部预约</label>
		<div class="layui-input-block">
		  <input type="radio" name="is_yuyue" value="1" title="是" >
		  <input type="radio" name="is_yuyue" value="0" title="否" checked>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">是否启用</label>
		<div class="layui-input-block">
		  <input type="radio" name="status" value="1" title="是" checked>
		  <input type="radio" name="status" value="0" title="否">
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
		  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
  </div>
</form>
<script>
	//Demo
	var ue = UE.getEditor('myEditor',{zIndex:1});
	layui.use(['form','rate','colorpicker'], function(){
        var rate = layui.rate;
          //基础效果
        rate.render({
              elem: '#rateNums',
              value: $('#level').val(),
              choose: function(res){
                  $('#level').val(res);
              }
        })
        var colorpicker = layui.colorpicker;
        //渲染
        colorpicker.render({
            elem: '#layColor'  //绑定元素
            ,color:$('#color').val()
            ,change: function(color){
                $('#color').val(color);
            }
        });
        var form = layui.form;
        layui.use('upload', function(){
        	var $ = layui.jquery
        	,upload = layui.upload;
        	var uploadInst = upload.render({
        		elem: '#test2'
        		,url: "{:U('Common/uploadImage')}"
        		,size:'0'
        		,exts:'jpeg|gif|png|jpg'
        		,multiple: false
        		,method: 'POST'
        		,before: function(obj){
        			//预读本地文件示例，不支持ie8
        			obj.preview(function(index, file, result){
        				$('#demo2').html('<div class="imgcss"><input type="hidden" name="image_url" id="smallimage1"><img src="'+result+'" width="150"></div>'); //文件名
        			});
        		}
        		,done: function(res){
        			//如果上传失败
        			if(res.code==0){
        				return layer.msg(res.value);
        			}else{
        				$('#smallimage1').val(res.value);
        			}
        		}
        		,error: function(){
        			//演示失败状态，并实现重传
        			var demoText = $('#demoText1');
        			demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        			demoText.find('.demo-reload').on('click', function(){
        				uploadInst.upload();
        			});
        		}
        	});
        });
        
        layui.use('upload', function(){
        	var $ = layui.jquery
        	,upload = layui.upload;
        	var uploadInst = upload.render({
        		elem: '#test3'
        		,url: "{:U('Common/uploadImage')}"
        		,size:'0'
        		,exts:'jpeg|gif|png|jpg'
        		,multiple: false
        		,method: 'POST'
        		,before: function(obj){
        			//预读本地文件示例，不支持ie8
        			obj.preview(function(index, file, result){
        				$('#demo3').html('<div class="imgcss"><input type="hidden" name="image_url2" id="smallimage2"><img src="'+result+'" width="150"></div>'); //文件名
        			});
        		}
        		,done: function(res){
        			//如果上传失败
        			if(res.code==0){
        				return layer.msg(res.value);
        			}else{
        				$('#smallimage2').val(res.value);
        			}
        		}
        		,error: function(){
        			//演示失败状态，并实现重传
        			var demoText = $('#demoText2');
        			demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        			demoText.find('.demo-reload').on('click', function(){
        				uploadInst.upload();
        			});
        		}
        	});
        });
        
		layui.use('laydate', function () {
			var laydate = layui.laydate;

			//执行一个laydate实例
			laydate.render({
				elem: '#time-select', //指定元素
				range: ['#startDate', '#endDate'],
				type: 'time'
			});

			laydate.render({
				elem: '#courseDate', //指定元素
				type: 'date'
			});
		});
        //监听提交
        form.on('submit(formDemo)', function(data){
        	var cont = data.field;
        	$.ajax({
        		url:"{:U('Course/repeatCourse')}",
        		type:'post',
        		dataType:'json',
        		data:cont,
        		success:function(data){
        			if(data.code==0){
        				layer.alert(data.message);
        			}else{
        				layer.alert(data.message, function(index){
        					//do something
        					window.parent.location.reload();
        					var index = parent.layer.getFrameIndex(window.name); 
        					parent.layer.close(index);
        				});
        			}
        		}
        	});
        	//layer.msg(JSON.stringify(data.field));
        	return false;
        });
});
</script>
<!-- /. PAGE INNER  -->
<include file="Common:footer" />